/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean;

import entity.PaymentItemEntity;
import entity.TransactionsEntity;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import session.stateful.TransactionSessionBean;

@ManagedBean(name="transactionManagerBean")
@SessionScoped
public class TransactionManagerBean {
    @EJB
    private TransactionSessionBean transactionSessionBean;
    private String selectedStakeholder=null;
    private String selectedCustomer=null;
    private List<TransactionsEntity> customerTransactionsList;
    private List<PaymentItemEntity> stakeholderTransactionsList;
    private Date date1;    
    private Date date2; 
    private SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
    
    public TransactionManagerBean() {
        this.date1=null;
        this.date2=null;
    }
    
    public void viewAllTransactions(){
        customerTransactionsList= transactionSessionBean.getAllCustomerTransactions();
        System.out.println(customerTransactionsList.size());
        stakeholderTransactionsList= transactionSessionBean.getAllStakeholderTransactions();
    }
    public void viewTransactionsByDate(){        
        customerTransactionsList= transactionSessionBean.getCustomerTransactionsByDate(date1, date2);
        stakeholderTransactionsList= transactionSessionBean.getStakeholderTransactionsByDate(date1, date2);           
    }

    public TransactionSessionBean getTransactionSessionBean() {
        return transactionSessionBean;
    }

    public void setTransactionSessionBean(TransactionSessionBean transactionSessionBean) {
        this.transactionSessionBean = transactionSessionBean;
    }

    public String getSelectedStakeholder() {
        return selectedStakeholder;
    }

    public void setSelectedStakeholder(String selectedStakeholder) {
        this.selectedStakeholder = selectedStakeholder;
    }

    public String getSelectedCustomer() {
        return selectedCustomer;
    }

    public void setSelectedCustomer(String selectedCustomer) {
        this.selectedCustomer = selectedCustomer;
    }

    public List<TransactionsEntity> getCustomerTransactionsList() {
        return customerTransactionsList;
    }

    public void setCustomerTransactionsList(List<TransactionsEntity> customerTransactionsList) {
        this.customerTransactionsList = customerTransactionsList;
    }

    public List<PaymentItemEntity> getStakeholderTransactionsList() {
        return stakeholderTransactionsList;
    }

    public void setStakeholderTransactionsList(List<PaymentItemEntity> stakeholderTransactionsList) {
        this.stakeholderTransactionsList = stakeholderTransactionsList;
    }

    public Date getDate1() {
        return date1;
    }

    public void setDate1(Date date1) {
        this.date1 = date1;
    }

    public Date getDate2() {
        return date2;
    }

    public void setDate2(Date date2) {
        this.date2 = date2;
    }

    public SimpleDateFormat getSdf() {
        return sdf;
    }

    public void setSdf(SimpleDateFormat sdf) {
        this.sdf = sdf;
    }

}
